package Practice11;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Student2Demo {
    public static void main(String[] args) {
        ArrayList<Student2> list= new ArrayList<Student2>();
        list.add(new Student2("rose1",132));
        list.add(new Student2("rose2",112));
        list.add(new Student2("rose3",132));
        list.add(new Student2("rose4",142));
        list.add(new Student2("rose5",112));
        list.add(new Student2("rose6",152));
        Collections.sort(list, new Comparator<Student2>() {
            @Override
            public int compare(Student2 o1, Student2 o2) {
                return o1.getAge()-o2.getAge();
            }
        });
        for (Student2 student2 : list) {
            System.out.println(student2);
        }

    }
}
